package org.ydsw.data.manage.mapper;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import org.ydsw.data.manage.entity.DealDictionaryEntity;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface DealDictionaryEntityMapper extends Mapper<DealDictionaryEntity> {

    // 批量新增
    @Insert("<script>" +
            "INSERT INTO eas_meta_data" +
            "        (table_name,table_ch_name,field_name,field_secondary_name,data_type,data_length,data_accuracy,data_decimal_count,data_tips)" +
            "        VALUES" +
            "        <foreach collection ='list' item='dealDictionaryEntity' separator =','>" +
            "            (#{dealDictionaryEntity.tableName}, #{dealDictionaryEntity.tableChName}, #{dealDictionaryEntity.fieldName},#{dealDictionaryEntity.fieldSecondaryName}, #{dealDictionaryEntity.dataType},#{dealDictionaryEntity.dataLength},#{dealDictionaryEntity.dataAccuracy}, #{dealDictionaryEntity.dataDecimalCount}, #{dealDictionaryEntity.dataTips})" +
            "        </foreach >" +
            "</script>")
    int insertDictionarys(@Param("list") List<DealDictionaryEntity> dealDictionaryEntitys);


    //查询已有的标准
    @Select("select table_name,table_ch_name,field_name,field_secondary_name from eas_meta_data WHERE table_name like 'T_SCM%' ")
    @Results(
            id = "meta1",
            value = {
                    @Result(property = "tableName",column = "table_name"),
                    @Result(property = "tableChName",column = "table_ch_name"),
                    @Result(property = "fieldName",column = "field_name"),
                    @Result(property = "fieldSecondaryName",column = "field_secondary_name"),
            }
    )
    List<DealDictionaryEntity> selectMetaData();



}

//,field_secondary_name,data_type,data_length,data_accuracy,data_decimal_count,data_tips
